import { http } from '@/http/http'

/**
 * 添加银行卡信息
 */
export function bankInfo(data) {
  return http.post<any>('/investor/user/bank_info', data)
}

/**
 * 获取用户信息
 */
export function userInfoApi(token) {
  return http.get<any>('/investor/user/default/info', { token })
}

/**
 * 查看银行卡信息
 */
export function viewBankInfo() {
  return http.get<any>('/investor/user/bank_info')
}

/**
 * 借款产品列表
 */
export function productList(data: {
  page: number
  size: number
  product_name: string
  status: number
}) {
  return http.get<any>('/investor/partner/product/list', data)
}

/**
 * 计算产品利息
 */
export function loanCalc(data: {
  product_id: number
  principal: number
  periods: number
}) {
  return http.get<any>('/investor/partner/loan/calc', data)
}

/**
 * 提交借款申请
 */
export function addLoanApplication(data: {
  product_id: number
  installment_periods: number
  repayment_method: number
  loan_class: number
  bank_name: string
  bank_user: string
  bank_no: string
  principal: number
  periods: number
}) {
  return http.post<any>('/investor/partner/loan/add', data)
}

/**
 * 文件上传
 */
export function upImage(data: {
  file: File
}) {
  return http.post<any>('/tenant/common/image/community', data)
}

/**
 * 获取直传参数
 */
export function getOssInfo() {
  return http.get<any>('/tenant/common/get_oss_info/post')
}

/**
 * 身份信息上传
 * user_id 用户id
 * data{
 * name 真实姓名
 * identifyId 身份证号码
 * identifyFront 身份证人像面
 * identifyBack 身份证国徽面
 * }
 */
export function identityVerify(user_id, data) {
  return http.put<any>(`/investor/user/${user_id}/verify`, data)
}

/**
 * 获取身份信息
 */
export function useVerify() {
  return http.get<any>(`/investor/user/verify`)
}

/**
 * 查询借款工单
 * data{
 * loan 借款人姓名/电话
 * }
 */
export function loanOrderList(data) {
  return http.get<any>(`/investor/partner/loan/list`, data)
}

/**
 * 还款
 * schedule_id 还款计划id
 * data{
 * repayment_voucher 还款凭证
 * }
 */
export function repayment(schedule_id, data) {
  return http.put<any>(`/investor/partner/repayment/${schedule_id}`, data)
}

/**
 * 计算待还款数据
 * user_id 用户id 财务查询某个人的数据时传入
 */
export function repaymentData(data) {
  return http.get<any>(`/investor/partner/repayment/data`, data)
}

/**
 * 查看还款记录
 * loan_id  借款工单id
 * data {
 * is_pay 是否还款 -1 未还款 0 待还款 1 已还款
 *  page 1
 *  size 999
 * } 数据
 */
export function getRepayment(loan_id, data) {
  return http.get<any>(`/investor/partner/repayment/list/${loan_id}`, data)
}

/**
 * 企业认证
 * data{
 *  legal_name 法人姓名
 *  legal_telephone 法人电话
 *  license_photo 经营执照
 *  bank_no 对公账户卡号
 * bank_user 对公账户持卡人姓名
 * bank_name 对公账户开户银行
 * bank_branch 对公账户开户支行
 * bank_addr 对公账户开户银行地址
 * }
 */
export function corporateAuth(data) {
  return http.post<any>(`/investor/partner/corporate/auth`, data)
}

/**
 * 后台企业列表查询
 */
export function salesCompany(data) {
  return http.get<any>(`/platform/user/sales/company`, data)
}

/**
 * 企业认证信息查询
 */
export function corporateAuthInfo() {
  return http.get<any>(`/investor/partner/corporate/auth`)
}

/**
 * 删除企业认证信息
 */
export function delCorporateAuth(record_id) {
  return http.delete<any>(`/investor/partner/corporate/auth/${record_id}`)
}
